# Compilation des executables de bebopframework
EXE = bopsimu bopipe bopin boprezo bop2c bop2vlog bop2xml boptouch bopmap
SOURCES = $(foreach file, $(EXE), $(file).ml)

SOURCES_DOC = listMap.ml message.ml inputtools.ml circuit.ml optimiseCds.ml cdsmaker.ml inputmaker.ml traitement.ml simulation.ml metatools.ml bop2tools.ml vlogtools.ml $(SOURCES)

BEBOPLIB = bebop.cmxa
BPLIB = bplib.cmxa
OTHERLIBS = unix.cmxa graphics.cmxa

CMXMake = NativeCodeMakefile
CMOMake = ByteCodeMakefile

task = ocamlopt $(OTHERLIBS) $(BPLIB) $(BEBOPLIB)

all : $(BPLIB) $(BEBOPLIB) $(EXE)

cma :
	make -C bplib cma
	make -f $(CMOMake)

dev : bplib.cmxa cma
	make -f NativeCodeMakefile


Wexe : $(EXE)

$(BPLIB) :
	make -C bplib
	cp -t . bplib/*.cmxa bplib/*.a bplib/*.cmi

$(BEBOPLIB) : $(SOURCES)
	make -f $(CMXMake)

bopmap : bopmap.ml bplib.cmxa bebop.cmxa 
	$(task) $< -o $@

bopsimu : bopsimu.ml bebop.cmxa 
	$(task) $< -o $@
#	cp $@ ../bin/.

bopipe : bopipe.ml bebop.cmxa 
	$(task) $< -o $@
#	cp $@ ../bin/.

bopin : bopin.ml bebop.cmxa
	$(task) $< -o $@
#	cp $@ ../bin/.

bop2c : bop2c.ml bebop.cmxa 
	$(task) $< -o $@
#	cp $@ ../bin/.

bop2vhdl : bop2vhdl.ml bebop.cmxa 
	$(task) $< -o $@
#	cp $@ ../bin/.

boptouch : boptouch.ml bebop.cmxa 
	$(task) $< -o $@

bop2vlog : bop2vlog.ml bebop.cmxa 
	$(task) $< -o $@

bop2xml : bop2xml.ml bebop.cmxa 
	$(task) $< -o $@

boprezo : boprezo.ml bebop.cmxa 
	$(task) -thread threads.cmxa $< -o $@

doc :
	make -C bplib bplib.cma
	cp -t . bplib/*.cma bplib/*.a bplib/*.cmi
	make -f $(CMOMake)
	mkdir -p html
	ocamldoc -d html -html $(SOURCES_DOC)

clean : 
	rm -f *.cmx *.cmi *.o *.cmo *.cmxa *.cma *.a
	make -f $(CMOMake) clean
	make -f $(CMXMake) clean
	rm -f $(EXE)

tilde :
	rm -f *~

uninstall : clean

